package com.bdqn.bookshop.common;

/**
 * @author : 罗若然[LUO_RUO_RAN]
 * @date : 2020-07-24 10:41
 * 书籍状态（1:已发布，2:交易中，3:交易完成，4:已下架）
 **/
public enum  BookStateEnum {

    DEFAULT(0, "ERROR"),
    BOOK_STATE_ISSUE(1, "发布中"),
    BOOK_STATE_TRADING(2, "交易中"),
    BOOK_STATE_SUCCESS(3, "交易成功"),
    BOOK_STATE_SOLDOUT(4, "已下架");

    private int state;

    private String name;

    BookStateEnum(int state, String name) {
        this.state = state;
        this.name = name;
    }

    public static BookStateEnum getBookState(int state) {
        for (BookStateEnum bookStateEnum : BookStateEnum.values()) {
            if (bookStateEnum.getState() == state) {
                return bookStateEnum;
            }
        }
        return DEFAULT;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
